package de.baumann.browser.activitys.duobao

import android.content.Context
import android.content.Intent
import de.baumann.browser.R
import de.baumann.browser.adapter.DuoBaoJiangPinAdapter
import de.baumann.browser.api.net.vo.duobao.DuoBao
import de.baumann.browser.base.BaseOdinActivity
import de.baumann.browser.base.BasePresenter
import de.baumann.browser.iview.IBaseView
import de.baumann.browser.iview.duobao.IJiangPinView
import de.baumann.browser.present.duobao.JiangPinPresenter
import kotlinx.android.synthetic.main.activity_duo_bao_jiang_pin.*
import kotlinx.android.synthetic.main.include_tool_bar_2.*

class DuoBaoJiangPinActivity : BaseOdinActivity<IJiangPinView, JiangPinPresenter>(), IJiangPinView {

    companion object {
        fun startDuoBaoJiangPinActivity(context: Context) {
            context.startActivity(Intent(context, DuoBaoJiangPinActivity::class.java))
        }
    }

    private lateinit var jiangPinAdapter: DuoBaoJiangPinAdapter

    override fun getLayout(): Int {
        return R.layout.activity_duo_bao_jiang_pin
    }

    override fun getTitleText(): String {
        return "获得奖品"
    }

    override fun getBackIcon(): Int {
        return R.drawable.ic_back
    }

    override fun initView() {
        initToolbar(commToolBar, commTitle)
        jiangPinAdapter = DuoBaoJiangPinAdapter()
        jiangPinList.adapter = jiangPinAdapter
    }

    override fun initData() {
        presenter?.jiangPinList()
    }

    override fun createPresenter(): JiangPinPresenter {
        return JiangPinPresenter()
    }

    override fun createView(): IJiangPinView {
        return this
    }

    override fun setJiangPinList(list: List<DuoBao>) {
        jiangPinAdapter.setNewData(list)
    }

}